1 // Equipo Poncho, Carriel y Ruana
23 template <class T
> string
toStr(const T
&x
)
24 { stringstream s
; s
<< x
; return s
.str(); }
25 template <class T
> int toInt(const T
&x
)
26 { stringstream s
; s
<< x
; int r
; s
>> r
; return r
; }
28 #define For(i, a, b) for (int i=(a); i<(b); ++i)
29 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
30 #define D(x) cout << #x " = " << (x) << endl;
32 const double EPS
= 1e-9;
34 int cmp(double x
, double y
= 0, double tol
= EPS
) {
35 return (x
<= y
+ tol
) ? (x
+ tol
< y
) ? -1 : 0 : 1;
42 while (scanf("%d %d", &n
, &m
) == 2) {
43 if (n
== 0 and m
== 0) break;
44 int k
; scanf("%d", &k
);
45 for (int i
= 0; i
< k
+ 1; ++i
) {
46 scanf("%d", °ree
[i
]);
50 for (int x
= 0; x
<= m
; x
++){
53 for (int i
= 0; i
< k
+ 1; ++i
) {
54 y
+= (1LL * degree
[i
] * d
) % mod
;
55 if (y
>= mod
) y
-= mod
;
57 d
= (1LL * d
* x
) % mod
;
61 printf("%d\n", (int)ans
.size());